home *** CD-ROM | disk | FTP | other *** search
/ Macademic for Students & Teachers / Macademic for Students and Teachers (Quantum Leap)(1992).iso / Mathematics / Age⁄Year Calculator / My Age⁄Year Calc.BAS < prev   
BASIC Source File  |  1991-01-29  |  20KB  |  692 lines

  1. '             ___________________________________________
  2. '    PROGRAM:fl‡      Age & Birth Year Calculator       ·‚
  3. '            fl———————————————————————————————————————————‚
  4. '            fl      _________________________________    ‚ 
  5. '            fl     fl⁄€€€€   January 21, 1991     €€€‹‚   ‚ 
  6. '            fl     fl—————————————————————————————————››  ‚
  7. '            fl     fl     By: Michael D. Powell       ››  ‚
  8. '            fl     fl        Copyright 1991           ››  ‚
  9. '            fl     fl     Master Data Processing      ››  ‚
  10. '            fl     fl                                 ››  ‚
  11. '            fl      ——›››››››››››››››››››››››››››››››››  ‚
  12. '            fl                                           ‚
  13. '             ———————————————————————————————————————————
  14. '
  15. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  16. 'Configuration Remarks
  17. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  18. '         Default variable type:Integer
  19. '   Space req'd after key words:Yes
  20. '                  Array base 1:No
  21. '                     File Type:ZHEX
  22. '                  Creator Type:AGCL
  23. '
  24.  DEF OPEN ="ZHEXAGCL"
  25.  BUNDLE = 1
  26. '
  27. '
  28. '
  29. WINDOW OFF:COORDINATE WINDOW
  30. DEF MOUSE=-1:CURSOR 4:WIDTH -2
  31. '
  32. '
  33. '
  34. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  35. 'Resources
  36. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  37. Hndl& = FN GETRESOURCE(CVI("AGCL"),0)
  38. LONG IF Hndl& = 0
  39.   ResRef = FN OPENRESFILE("Age/Year Calc.RES")
  40. END IF
  41. '
  42. '
  43. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  44. 'Equates
  45. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  46. YOBA$ = "**"
  47. YOBB$ = "**"
  48. YS$ = "*****"
  49. DIM T,L,B,R:'                                                 Generic rectangles
  50. DIM My,Mx,GlobalY,GlobalX,LocalY,LocalX:'                           Mouse points
  51. DIM Ft,Fl,Fb,Fr,Fy,Fx:'                               Rect & point for functions
  52.     True = NOT(False)
  53. DIM KeyRecord(7):'                             Record structure for keyboard map
  54. DIM FAsc,FDes,FWid,FLead,Fht:'              Record structure for font dimensions
  55. DIM 40 BtnName$,40 CtrlTitle$:'                   Simple string for button names
  56. DIM 1 Cr$:Cr$= CHR$(13):'                                       Return character
  57. DIM 1 Q$ :Q$ = CHR$(34):'                                             Quote mark
  58. DIM PenSpecs$:'                                           Holds current pen data
  59. '
  60. DIM ScrnT,ScrnL,ScrnB,ScrnR:'                                Rect of main screen
  61.     CALL GETWMGRPORT(WMgrPort&):'                        Ptr to desktop grafport
  62.     BLOCKMOVE WMgrPort&+8,VARPTR(ScrnT),8:'        Move its rect to my structure
  63. '
  64.     Arrow       =  0:IBeam     =  1:'                                    Cursors
  65.     CrossHair   =  2:Plus      =  3
  66.     Watch       =  4:Hand      = 1000
  67. '
  68.     ButtonAct   =  1:FieldAct  =  2:'                              Dialog events
  69.     WindowAct   =  3:CloseAct  =  4
  70.     RefreshAct  =  5:ReturnAct =  6
  71.     TabAct      =  7:ZoomInAct =  8
  72.     ZoomOutAct  =  9:ShTabAct  = 10
  73.     ClearAct    = 11:LeftAct   = 12
  74.     RightAct    = 13:UpAct     = 14
  75.     DownAct     = 15:KeyAct    = 16
  76.     DiskAct     = 17
  77. '
  78. '
  79. '
  80. DIM Stak(20):'                                                    My event stack
  81.     StakHi = 20:'                                             Max items on stack
  82.     SP = 0:'                                                       Stack pointer
  83.     OpenEvent  = 1:'                                    Request to open a window
  84.     CloseEvent = 2:'                             Request that a window be closed
  85.     MenuEvent  = 3:'                         Request that menu be de-highlighted
  86.     BreakEvent = 4:'                          Request that program be terminated
  87. '
  88.     Main = 1
  89.     About = 2
  90.     Year = 3
  91. GOTO"Queue"
  92. '
  93. '
  94. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  95. 'Functions
  96. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  97. '
  98. '                                               Set the font and calc its height
  99. '
  100. LONG FN GetFht(GFFont,GFSize,GFFace,GFMode)
  101.   TEXT GFFont,GFSize,GFFace,GFMode
  102.   CALL GETFONTINFO(FAsc)
  103. END FN = FAsc+FDes+FLead
  104. '
  105. '                                             Capture offset values from handles
  106. '
  107. DEF FN  GetWord(GWHndl&,GWOffSet)=PEEK WORD(PEEK LONG(GWHndl&)+GWOffSet)
  108. DEF FN GetLong&(GLHndl&,GLOffSet)=PEEK LONG(PEEK LONG(GLHndl&)+GLOffSet)
  109. '
  110. '                                             Place an integer on my event stack
  111. '
  112. LONG FN Push(PushVal)
  113.   IF SP+1>StakHi THEN SP=StakHi-1
  114.   SP = SP + 1
  115.   Stak(SP) = PushVal
  116. END FN
  117. '
  118. '                                                Remove an integer from my stack
  119. '
  120. LONG FN Pop
  121.   LONG IF SP
  122.     PopVal = Stak(SP)
  123.     SP = SP - 1
  124.   XELSE
  125.     PopVal = 0
  126.   END IF
  127. END FN = PopVal
  128. '
  129. '                                   Refresh a window without bringing it forward
  130. '
  131. LONG FN Format(Wnd2Format)
  132.   LONG IF Wnd2Format
  133.     OldOutPutWnd = WINDOW(1)
  134.     WINDOW OUTPUT Wnd2Format
  135.     GOSUB"Format Wnd"
  136.     IF OldOutPutWnd THEN WINDOW OUTPUT OldOutPutWnd
  137.   END IF
  138. END FN
  139. '
  140. '                                                        Locate a button by name
  141. '
  142. LONG FN FindBtn&(BtnName$)
  143.   FndBtnHndl&=PEEK LONG(WINDOW(14)+140)
  144.   DO
  145.     CALL GETCTITLE(FndBtnHndl&,CtrlTitle$)
  146.     LONG IF BtnName$<>CtrlTitle$
  147.       FndBtnHndl&=PEEK LONG(PEEK LONG(FndBtnHndl&))
  148.     END IF
  149.   UNTIL BtnName$=CtrlTitle$ OR FndBtnHndl&=0
  150. END FN = FndBtnHndl&
  151. '
  152. '                                      Change cursor according to mouse position
  153. '
  154. LONG FN AutoCursor(Fy,Fx)
  155.   ACResult = Arrow
  156.   LONG IF WINDOW(0)
  157.     ACHndl& = TEHANDLE(WINDOW(0))
  158.     LONG IF ACHndl&
  159.       BLOCKMOVE PEEK LONG(ACHndl&),VARPTR(Ft),8
  160.       IF FN PTINRECT(Fy,Ft) THEN ACResult = IBeam
  161.      END IF
  162.     ACPort& = WINDOW(14)
  163.     LONG IF ACPort&
  164.       LONG IF FN FINDCONTROL(Fy,ACPort&,ACHndl&)
  165.         ACResult = Hand
  166.       END IF
  167.     END IF
  168.   END IF
  169. END FN = ACResult
  170. '
  171. '                                            Check 1 menu item & return its name
  172. '
  173. LONG FN Chk1Item$(MHndl&,ChkItem)
  174.   FOR F=1 TO FN COUNTMITEMS(MHndl&)
  175.     CALL CHECKITEM(MHndl&,F,(F=ChkItem))
  176.   NEXT
  177.   CALL GETITEM(MHndl&,ChkItem,ItemName$)
  178. END FN=ItemName$
  179. '
  180. '
  181. '
  182. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  183. "Queue"
  184. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  185.  GOSUB"Initialize":'                                     Execute set-up routines
  186.  FLUSHEVENTS:'                                   Remove any events since startup
  187.  ON BREAK  GOSUB"Break":'                                        Set up handlers
  188.  ON DIALOG GOSUB"Dialog"
  189.  ON MOUSE  GOSUB"Mouse"
  190.  ON MENU   GOSUB"Menu"
  191.  CURSOR Arrow:'                                             Restore arrow cursor
  192. '
  193. '
  194. '
  195. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  196. "Loop"
  197. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  198. '
  199.  DIALOG ON :MOUSE ON :BREAK ON :MENU ON
  200.  DIALOG OFF:MOUSE OFF:BREAK OFF:MENU OFF:'     The only place events are trapped
  201. '
  202. '                                                      Handle events on my stack
  203. '
  204. WHILE SP:'                                      Is the stack pointer above zero?
  205.   MyEvent=FN Pop:'                                  Pop the event from the stack
  206.   SELECT MyEvent:'                                            React to the event
  207.     CASE OpenEvent:'                                   Request to build a window
  208.       GOSUB"Build"
  209.     CASE CloseEvent:'                                  Request to close a window
  210.       Wnd2Close = FN Pop:'                   Pop # of window to close from stack
  211. '                                 Bring it to the front for the capture routines
  212.       IF WINDOW(0)<>Wnd2Close THEN WINDOW Wnd2Close
  213.       GOSUB"Capture":'                               Capture data before closing
  214.       WINDOW CLOSE Wnd2Close:'                                          Close it
  215.     CASE MenuEvent:'                                 Request to de-hilite a menu
  216.       MENU
  217.     CASE BreakEvent:'                                       Request to terminate
  218.       LONG IF WINDOW(0)
  219. '                          Close open windows 1st to handle list/region disposal
  220.         FN Push(BreakEvent)
  221.         FN Push(WINDOW(0))
  222.         FN Push(CloseEvent)
  223.       XELSE
  224.         PleaseTerminate=True
  225.       END IF
  226.   END SELECT:'                                             End of event handlers
  227.   IF PleaseTerminate=True THEN "Break":'    Cont while events remain on my stack
  228. WEND
  229. '
  230. '                                                   Set cursor by mouse position
  231. '
  232.  OldCsr=NewCsr:'                                             Save the old cursor
  233.  NewCsr=Arrow:'                                        Reset new cursor to arrow
  234.  CALL GETMOUSE(My):'                                         Where is the mouse?
  235.  NewCsr=FN AutoCursor(My,Mx):'                                Let the FN tell us
  236.  IF NewCsr<>OldCsr THEN CURSOR NewCsr:'               If the cursor has changed…
  237. '
  238. GOTO"Loop"
  239. '
  240. '
  241. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  242. "Dialog"
  243. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  244.  Act=DIALOG(0):Ref=DIALOG(Act)
  245. '
  246.  LONG IF Act=CloseAct
  247.    FN Push(Ref):FN Push(CloseEvent)
  248.    RETURN
  249.  END IF
  250. '
  251.  IF Act=RefreshAct THEN FN Format(Ref):RETURN
  252. '
  253.  IF Act=ClearAct THEN EDIT FIELD Ref,"":RETURN
  254. '
  255. '
  256.  LONG IF Act=WindowAct
  257.    GOSUB"Capture"
  258.    WINDOW Ref
  259.    RETURN
  260.  END IF
  261. '
  262. '
  263.  LONG IF WINDOW(0) = Main
  264.  
  265.    LONG IF Act = ButtonAct            'WINDOW 1  DIALOG routines here
  266.    
  267.    SELECT Ref
  268.  
  269.    CASE 1
  270.     LONG IF VAL(EDIT$(1)) > 1799 AND VAL(EDIT$(1)) < 1997
  271.  
  272.      GOSUB "Capture"
  273.    
  274.     XELSE
  275.  
  276.      EDIT FIELD 1,"?"
  277.      BB$ = "?":AB$ = "?"
  278.      GOSUB "Format Wnd"
  279.  
  280.     END IF
  281.  
  282.    CASE 2
  283.     YS$ = "*****"
  284.     BB$ = "?":AB$ = "?"
  285.     EDIT FIELD 1,"?"
  286.     BUTTON 1,0:BUTTON 2,0
  287.     FOR X = 4 TO 9:BUTTON X,1:NEXT X
  288.     GOSUB "Format Wnd"
  289.  
  290.    CASE 3
  291.     YS$ = "*****"
  292.     BB$ = "?":AB$ = "?"
  293.     EDIT FIELD 1,"?"
  294.     FN Push(1):FN Push(CloseEvent)
  295.  
  296.    CASE 4
  297.     BUTTON 1,2:BUTTON 2,2
  298.     FOR X = 4 TO 9:BUTTON X,0:NEXT X
  299.     YS$ = "1991"
  300.     GOSUB "Format Wnd"
  301.  
  302.    CASE 5
  303.     BUTTON 1,2:BUTTON 2,2
  304.     FOR X = 4 TO 9:BUTTON X,0:NEXT X
  305.     YS$ = "1992"
  306.     GOSUB "Format Wnd"
  307.  
  308.    CASE 6
  309.     BUTTON 1,2:BUTTON 2,2
  310.     FOR X = 4 TO 9:BUTTON X,0:NEXT X
  311.     YS$ = "1993"
  312.     GOSUB "Format Wnd"
  313.  
  314.    CASE 7
  315.     BUTTON 1,2:BUTTON 2,2
  316.     FOR X = 4 TO 9:BUTTON X,0:NEXT X
  317.     YS$ = "1994"
  318.     GOSUB "Format Wnd"
  319.  
  320.    CASE 8
  321.     BUTTON 1,2:BUTTON 2,2
  322.     FOR X = 4 TO 9:BUTTON X,0:NEXT X
  323.     YS$ = "1995"
  324.     GOSUB "Format Wnd"
  325.  
  326.    CASE 9
  327.     BUTTON 1,2:BUTTON 2,2
  328.     FOR X = 4 TO 9:BUTTON X,0:NEXT X
  329.     YS$ = "1996"
  330.     GOSUB "Format Wnd"
  331.  
  332.     END SELECT
  333.  
  334.    END IF
  335.  
  336.    RETURN
  337.  
  338.  END IF
  339. '
  340. '
  341.  LONG IF WINDOW(0) = Year
  342.   
  343.   LONG IF Act = ButtonAct    'WINDOW 3  DIALOG routines here
  344.  
  345.    SELECT Ref
  346.  
  347.     CASE 1
  348.      BY = 1991
  349.      FOR X = 1 TO 4:BUTTON X,0:NEXT X
  350.      BUTTON 5,2:BUTTON 6,2
  351.  
  352.     CASE 2
  353.      BY = 1992
  354.      FOR X = 1 TO 4:BUTTON X,0:NEXT X
  355.      BUTTON 5,2:BUTTON 6,2
  356.  
  357.     CASE 3
  358.      BY = 1993
  359.      FOR X = 1 TO 4:BUTTON X,0:NEXT X
  360.      BUTTON 5,2:BUTTON 6,2
  361.  
  362.     CASE 4
  363.      BY = 1994
  364.      FOR X = 1 TO 4:BUTTON X,0:NEXT X
  365.      BUTTON 5,2:BUTTON 6,2
  366.  
  367.     CASE 5
  368.      GOSUB "Capture"
  369.      GOSUB "Format Wnd"
  370.  
  371.     CASE 6
  372.      EDIT FIELD 1,"?"
  373.      FOR X = 1 TO 4:BUTTON X,1:NEXT X
  374.      BUTTON 5,0:BUTTON 6,0
  375.      YOBA$ = "**"
  376.      YOBB$ = "**"
  377.      GOSUB "Format Wnd"
  378.  
  379.     CASE 7
  380.      EDIT FIELD 1,"?"
  381.      FN Push(3):FN Push(CloseEvent)
  382.  
  383.  
  384.    END SELECT
  385.  
  386.   END IF
  387.  
  388.    RETURN
  389.  
  390.  END IF
  391.  
  392. RETURN
  393. '
  394. '
  395. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  396. "Mouse"
  397. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  398.  Mact=MOUSE(0):Mx=MOUSE(1):My=MOUSE(2)
  399. '
  400. LONG IF WINDOW(1) = About
  401. MOUSE ON
  402. DO
  403. Mact = MOUSE(0)
  404. UNTIL Mact <> 0
  405. MOUSE OFF
  406. FN Push(2):FN Push(CloseEvent)
  407. END IF
  408.  
  409.  DO:UNTIL MOUSE(0)=0
  410. RETURN
  411. '
  412. '
  413. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  414. "Menu"
  415. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  416.  MenuID=MENU(0):ItemID=MENU(1)
  417.  FN Push(MenuEvent)
  418.  
  419.  LONG IF MenuID = 255:'                                               Apple menu
  420.  
  421.  FN Push(2)                        '<-- Put "About..." handlers here
  422.  FN Push(OpenEvent)
  423.  
  424.  RETURN
  425.  
  426.  END IF
  427.  
  428.  ON MenuID GOTO "File"
  429.  
  430. "File"
  431.  
  432.  ON ItemID GOTO "Calc Age","Calc Year","X","Quit"
  433.  
  434. "Calc Age"
  435.  BB$ = "?":AB$ = "?"
  436.  FN Push(1):FN Push(OpenEvent)
  437.  
  438.  RETURN
  439.  
  440. "Calc Year"
  441.  YOBA$ = "**":YOBB$ = "**"
  442.  FN Push(3):FN Push(OpenEvent)
  443.  
  444.  RETURN
  445.  
  446. "Quit" GOTO "Break"
  447.  
  448. "X"
  449.  
  450.  RETURN
  451. '
  452. '
  453. '
  454. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  455. "Break"
  456. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  457. '
  458.  IF WINDOW(0) THEN FN Push(BreakEvent):RETURN
  459. '
  460.  IF ResRef>0 THEN CALL CLOSERESFILE(ResRef)
  461. '
  462. END
  463. '
  464. '
  465. '
  466. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  467. 'Window Routines
  468. '∑∑∑œœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœœ∑∑∑
  469. '
  470. '
  471. '”’”’”’”’”’”’”’”’”’’
  472. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  473. "Build"
  474. '”’”’”’”’”’”’”’”’”’’
  475. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  476.  Wnd2Build = FN Pop:'                                    Pop window # from stack
  477.  
  478.  SELECT Wnd2Build
  479.   
  480.   CASE Main
  481.      T = 0:L = 0:B = 278:R = 420:'                       Set TLBR to window size
  482. '                                    Offset the rect to the center of the screen
  483.      CALL OFFSETRECT(T,ScrnR/2-R/2,(ScrnB/2+8)-B/2)
  484.      WINDOW Wnd2Build,"Window #1",(L,T)-(R,B),-2
  485.      TEXT 0,12,0,0
  486.      EDIT FIELD 1,"?",( 56, 89)-( 112, 105),1,2
  487.      BUTTON 1, 0,"Calculate Age",( 55, 115)-( 172, 131),3
  488.      BUTTON 2, 0,"Clear",( 36, 145)-( 103, 161),3
  489.      BUTTON 3, 2,"Cancel",( 106, 145)-( 173, 161),3
  490.      BUTTON 4, 1,"1991",( 274, 186)-( 321, 206),1
  491.      BUTTON 5, 1,"1992",( 331, 186)-( 378, 206),1
  492.      BUTTON 6, 1,"1993",( 274, 210)-( 321, 230),1
  493.      BUTTON 7, 1,"1994",( 331, 210)-( 378, 230),1
  494.      BUTTON 8, 1,"1995",( 275, 234)-( 322, 254),1
  495.      BUTTON 9, 1,"1996",( 332, 234)-( 379, 254),1
  496.    
  497.    CASE About
  498.      T = 0:L = 0:B = 109:R = 248:'                       Set TLBR to window size
  499. '                                    Offset the rect to the center of the screen
  500.      CALL OFFSETRECT(T,ScrnR/2-R/2,(ScrnB/2+8)-B/2)
  501.      WINDOW Wnd2Build,"Window #2",(L,T)-(R,B),-2
  502.    
  503.    CASE Year
  504.      T = 0:L = 0:B = 251:R = 333:'                       Set TLBR to window size
  505. '                                    Offset the rect to the center of the screen
  506.      CALL OFFSETRECT(T,ScrnR/2-R/2,(ScrnB/2+8)-B/2)
  507.      WINDOW Wnd2Build,"Window #3",(L,T)-(R,B),-2
  508.      BUTTON 1, 1,"1991",( 179, 64)-( 227, 84),1
  509.      BUTTON 2, 1,"1992",( 239, 64)-( 284, 84),1
  510.      BUTTON 3, 1,"1993",( 178, 88)-( 226, 108),1
  511.      BUTTON 4, 1,"1994",( 240, 88)-( 285, 108),1
  512.      BUTTON 5, 0,"Find Year",( 31, 222)-( 116, 238),3
  513.      BUTTON 6, 0,"Clear",( 150, 222)-( 215, 238),3
  514.      BUTTON 7, 2,"Cancel",( 243, 222)-( 308, 238),3
  515.      TEXT 0,12,0,0
  516.      EDIT FIELD 1,"?",( 36, 67)-( 92, 83),1,2
  517.  
  518.  END SELECT
  519.  
  520. RETURN
  521. '
  522. '
  523. '”’”’”’”’”’”’”’”’”’’
  524. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  525. "Format Wnd"
  526. '”’”’”’”’”’”’”’”’”’’
  527. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  528. '
  529.  CALL GETPENSTATE(PenSpecs$):'                      Record the current pen state
  530. '
  531.  TxFont=PEEK WORD(WINDOW(14)+68):'                 Record the current font specs
  532.  TxFace=PEEK WORD(WINDOW(14)+70)
  533.  TxMode=PEEK WORD(WINDOW(14)+72)
  534.  TxSize=PEEK WORD(WINDOW(14)+74)
  535. '
  536. '
  537.  LONG IF WINDOW(1) = Main
  538.    T = 39:L = 243:B = 156:R = 414
  539.    PEN 8,3,1,8,19
  540.    CALL PAINTRECT(T)
  541.    PEN ,,1,8,0
  542.    CALL FRAMERECT(T)
  543.    T = 177:L = 7:B = 267:R = 204
  544.    CALL PENNORMAL:'                          If you haven't installed the proper
  545.    DEF SHADOWBOX(T):'                             ZMover library-this won't work
  546.    T = 122:L = 261:B = 143:R = 314
  547.    CALL PENNORMAL:'                          If you haven't installed the proper
  548.    DEF SHADOWBOX(T):'                             ZMover library-this won't work
  549.    T = 3:L = 2:B = 30:R = 419
  550.    TEXT 22,24,25,0
  551.    Temp$ = "Age Calculator"
  552.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  553.    T = 31:L = 4:B = 31:R = 416
  554.    PEN 1,1,1,8
  555.    CALL MOVETO(L,T):CALL LINETO(R,B)
  556.    T = 59:L = 57:B = 83:R = 114
  557.    TEXT ,12,1,0
  558.    Temp$ = "Year Of Birth"
  559.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  560.    T = 48:L = 260:B = 67:R = 398
  561.    TEXT 3,14,,0
  562.    Temp$ = YS$
  563.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  564.    T = 85:L = 253:B = 109:R = 320
  565.    TEXT 22,12,,0
  566.    Temp$ = "Before"+Cr$+"Birthday"
  567.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  568.    L = 333:R = 405
  569.    Temp$ = "After Birthday"
  570.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  571.    T = 123:L = 266:B = 139:R = 307
  572.    TEXT 0,,0,0
  573.    Temp$ = BB$
  574.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  575.    T = 121:L = 344:B = 145:R = 400
  576.    CALL PENNORMAL:'                          If you haven't installed the proper
  577.    DEF SHADOWBOX(T):'                             ZMover library-this won't work
  578.    T = 123:L = 352:B = 139:R = 393
  579.    Temp$ = AB$
  580.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  581.    T = 181:L = 11:B = 261:R = 200
  582.    Temp$ = "Select a Year button to the right.  Enter a year into the box above and click the calculate age button to receive the answer."
  583.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 0)
  584.    T = 72:L = 251:B = 72:R = 406
  585.    PEN 4,8,1,8
  586.    CALL MOVETO(L,T):CALL LINETO(R,B)
  587.    T = 76:L = 327:B = 151:R = 327
  588.    PEN 2,4,1,8
  589.    CALL MOVETO(L,T):CALL LINETO(R,B)
  590.  END IF:'                                                     End of Main format
  591. '
  592. '
  593.  LONG IF WINDOW(1) = About
  594.    T = 6:L = 5:B = 101:R = 243
  595.    TEXT 3,14,1,0
  596.    Temp$ = "Age Calculator"+Cr$+"by"+Cr$+"Michael D. Powell"+Cr$+"January 1991"+Cr$+"Written in ZBasic"
  597.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  598.  END IF:'                                                    End of About format
  599. '
  600. '
  601.  LONG IF WINDOW(1) = Year
  602.    T = 41:L = 167:B = 117:R = 295
  603.    PEN 4,6,1,8,3
  604.    CALL FRAMERECT(T)
  605.    T = 105:L = 5:B = 209:R = 139
  606.    CALL PENNORMAL:'                          If you haven't installed the proper
  607.    DEF SHADOWBOX(T):'                             ZMover library-this won't work
  608.    T = 5:L = 2:B = 32:R = 331
  609.    TEXT 22,24,24,0
  610.    Temp$ = "Year Calculator"
  611.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  612.    T = 31:L = 3:B = 31:R = 329
  613.    PEN 2,4,1,8,0
  614.    CALL MOVETO(L,T):CALL LINETO(R,B)
  615.    T = 46:L = 26:B = 62:R = 102
  616.    TEXT 0,12,0,0
  617.    Temp$ = "Enter Age"
  618.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  619.    T = 119:L = 142:B = 167:R = 332
  620.    Temp$ = "If the birthday for this year has past this person was born in:"
  621.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 0)
  622.    T = 151:L = 202:B = 167:R = 282
  623.    Temp$ = YOBA$
  624.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  625.    T = 48:L = 180:B = 60:R = 286
  626.    TEXT 22,,1,0
  627.    Temp$ = "Present Year:"
  628.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  629.    T = 106:L = 7:B = 202:R = 133
  630.    TEXT ,10,0,0
  631.    Temp$ = "You must first select the present year and then enter the age of the person in the box above.  Click find year to see when the person was born"
  632.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  633.    T = 170:L = 143:R = 322
  634.    TEXT 0,12,,0
  635.    Temp$ = "otherwise the correct year was:"
  636.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 0)
  637.    T = 186:L = 215:B = 202:R = 295
  638.    Temp$ = YOBB$
  639.    CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
  640.  END IF:'                                                     End of Year format
  641. '
  642. '
  643. TEXT TxFont,TxSize,TxFace,TxMode:'                        Restore the font specs
  644. '
  645.  CALL SETPENSTATE(PenSpecs$):'                                   Restore the pen
  646. '
  647. RETURN
  648. '
  649. '
  650. '”’”’”’”’”’”’”’”’”’’
  651. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  652. "Capture"
  653. '”’”’”’”’”’”’”’”’”’’
  654. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  655. '
  656.  LONG IF WINDOW(0) = Main
  657.  
  658.   YS = VAL(YS$)           'WINDOW 1  capture routines here
  659.   YRB = VAL(EDIT$(1))
  660.   BB = YS - (YRB+1):AB = YS - (YRB)
  661.   BB$ = STR$(BB):AB$ = STR$(AB)
  662.   GOSUB "Format Wnd"
  663.   
  664.  END IF
  665. '
  666.  LONG IF WINDOW(0) = Year
  667.  AG = VAL(EDIT$(1))        'WINDOW 3  capture routines here
  668.  YOBA = BY - AG
  669.  YOBB = (BY-1) - AG
  670.  YOBA$ = STR$(YOBA)
  671.  YOBB$ = STR$(YOBB)
  672.  END IF
  673. RETURN
  674. '
  675. '
  676. '
  677. '”’”’”’”’”’”’”’”’”’’
  678. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  679. "Initialize"
  680. '”’”’”’”’”’”’”’”’”’’
  681. '‘“‘“‘“‘“‘“‘“‘“‘“‘“‘
  682.  FN Push(2):'                                      Push first window on to stack
  683.  FN Push(OpenEvent):'                   Tell my event manager to open the window
  684.  APPLE MENU "About..."
  685.  MENU 1,0,1,"File"
  686.    MENU 1,1,1,"Calc Age/A"
  687.    MENU 1,2,1,"Calc Year/Y"
  688.    MENU 1,3,0,"-"
  689.    MENU 1,4,1,"Quit/Q"
  690. RETURN
  691. '
  692.